# Copyright (C) 2004, 2005  Fletcher T. Penney <fletcher@freeshell.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
#    Free Software Foundation, Inc.
#    59 Temple Place, Suite 330
#    Boston, MA 02111-1307 USA

sub SideBarContent {
    if (GetParam('action', '') eq 'edit') { return };

    my $id = $_[0];
    print $q->start_div({-class=>'sidewrap'});
    print $q->start_div({-class=>'sidewrap_bg'});
    print $q->start_div({-class=>'sidewrap_left'});
    print $q->start_div({-class=>'sidewrap_right'});
    print $q->start_div({-class=>'sidewrap_top'});
    print $q->start_div({-class=>'clearfix'});
    print $q->start_div({-class=>'sidecontent'});

    print "<a href=\"/HomePage\" title=\"Go Home!\" class=\"whitelogo\"><img src=\"/images/common/whitelogo.png\" alt=\"Go Home\" class=\"whitelogo\"/></a>";
  
    if (%SpecialDays) {
        my ($sec, $min, $hour, $mday, $mon, $year) = gmtime($Now);
        if ($SpecialDays{($mon + 1) . '-' . $mday}) {
            print "<p class=\"tagline\">" .  $SpecialDays{($mon + 1) . '-' . $mday} . "</p>"; 
        }
    }

    # Show Edit help if action = edit
    if (GetParam('action', '') eq 'edit') {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Edit Hints'));
        print $q->p(T('Be sure to add an appropriate WikiCategory and WikiTag.  See SitePolicy for submission details'));
        print $q->p({-class=>'sidetitle'},T('Edit Help'));
        print "<p><a href=\"/WikiWord\" class=\"local\">WikiWord</a>, <a href=\"/WikiMarkup\" class=\"local\">WikiMarkup</a>, <a href=\"/WikiTable\" class=\"local\">WikiTable</a>, <a href=\"/WikiImage\" class=\"local\">WikiImage</a>, and do not forget to pick a <a href=\"/WikiCategory\" class=\"local\">WikiCategory</a>/<a href=\"/WikiTag\" class=\"local\">WikiTag</a></p>";
        print $q->end_div();
    }
  
    if (GetParam('action', '') eq 'collect') {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Collection Hints'));
        print $q->p(T('This is a list of all articles in this collection.'));
        print $q->p(T('To see the original article (to edit it for example), click on its title.'));
        print $q->end_div();
    }

    if (GetParam('action', '') eq 'printable-index') {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Index Hints'));
        print $q->p(T('This is a list of all articles on this Wiki sorted alphabetically.'));
        print $q->p(T('This page can cause a signifigant amount of cpu load when loaded, so please browse responsibly.'));
        print $q->end_div();
    }

    if (GetParam('action', '') eq 'calendar') {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Calendar Hints'));
        print $q->p(T('This calendar only displays data from Journal entries.'));
        print $q->p(T('WikiNodes are not included with this view as most Wiki content is not date or time relavent material.'));
        print $q->p(T('Blue links represent a single journal entry for that day.  Green links represent more than one journal entry for that day.  Red highlights today.'));
        print $q->end_div();
    }

    if (((GetParam('search', '') ne '') or GetParam('action', '') eq 'searchmeta')) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Search Hints'));
        print $q->p(T('This is a list of all articles found by searching by keyword. If you cannot find the article in question, try browsing using the cloud map.'));
        print $q->end_div();
        print $q->start_div({-class=>'sideinlinenobold'});
        print $q->p({-class=>'sidetitle'},T('Tag Cloud'));
        &CoolCloud;
        print $q->end_div();
    }

    if ($id =~ /^$CommentsPrefix(.*)/) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Comment Hints'));
        print $q->p(T('Your username and the current timestamp will be appended to your comment.'));
        print $q->p(T('HTML markup is allowed, but please use WikiMarkup to keep things simple.'));
        print $q->p(T('Please preview your comment to ensure that it is correct.'));
        print $q->end_div();
    }

    if ($id eq $HomePage) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Key Pages'));
        PrintWikiToHTML(GetPageContent(KeyPages));
        print $q->end_div();
    }

    # Check for page, if exists - include it.
    if ($IndexHash{$id . "Links"}) { 
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Associated Links'));
        PrintWikiToHTML(GetPageContent($id . "Links"));
        print $q->end_div();
    }

    # Tag pages should include cloud
    if ($id =~ /^Tag.*/ ) {
        print $q->start_div({-class=>'sideinlinenobold'});
        print $q->p({-class=>'sidetitle'},T('Tag Cloud'));
        &CoolCloud;
        print $q->end_div();
    }
    
    # An explanation of what Taxonomy is
    if ($id =~ /^Taxonomy.*/ ) {
        print $q->start_div({-class=>'sideinlinenobold'});
        print $q->p({-class=>'sidetitle'},T('Taxonomy Page'));
        print $q->p(T('This page is a part of the Taxonomy system, a sort of Quasi-Wiki-Hierarchy.'));
        print $q->p(T('It allows me to group pages in different ways and play with page relationships.'));
        print $q->p(T('For those of you from the Blogoshere, try the tag cloud instead.'));
        print $q->end_div();
        print $q->start_div({-class=>'sideinlinenobold'});
        print $q->p({-class=>'sidetitle'},T('Tag Cloud'));
        &CoolCloud;
        print $q->end_div();
    }

    # If we are a journal page, include some linkage
    if ($id =~ /^Journal.*/ ) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Journal Hints'));
        print $q->p(T('This is a list of the most recent articles posted in this journal category.'));
        print $q->p(T('To see the original article (to edit it for example), click on its title.'));
        print $q->p(T('To navigate, pick a category or use the automatically generated tag cloud.'));
        print $q->end_div();
        print $q->start_div({-class=>'sideinlinenobold'});
        print $q->p({-class=>'sidetitle'},T('Tag Cloud'));
        &CoolCloud;
        print $q->end_div();
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Journal Categories'));
        PrintWikiToHTML(GetPageContent(JournalCategories));
        print $q->end_div();
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Blog Roll'));
        PrintWikiToHTML(GetPageContent(BlogRoll));
        print $q->end_div();
    }

    # Also print BlogRoll for Those Pages
    if ($id =~ /^Those.*/ ) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Blog Roll'));
        PrintWikiToHTML(GetPageContent(BlogRoll));
        print $q->end_div();
    }

    # If we belong to CharlesMauch, include yet more text
    if ($id =~ /^CharlesMauch.*/ ) {
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Wiki Sites'));
        print $q->a({-class=>'local', -href=>'http://wiki.archlinux.org/index.php/User:Xterminus', -title=>'Arch Wiki Madness!'},T('ArchWiki Articles'));
        print $q->a({-class=>'local', -href=>'http://www.taclug.org/wiki/User:Xterminus', -title=>'Its TacLug not TACLUG!'},T('TaclugWiki Articles'));
        print $q->a({-class=>'local', -href=>'http://en.wikipedia.com/index.php/User:Xterminus',-title=>'Wikipedia sucks!'},T('Wikipedia Articles'));
        print $q->end_div();
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Networking'));
        print $q->a({-class=>'local', -href=>'http://www.linkedin.com/in/charlesmauch',-title=>'I\'m Linked in Baybee!'},T('LinkedIn Profile'));
        print $q->a({-class=>'local', -href=>'http://www.last.fm/user/cmauch/',-title=>'Music for the Smart Masses'},T('Last.FM Dashboard'));
        print $q->a({-class=>'local', -href=>'http://www.myspace.com/charlesmauch',-title=>'Where teenagers live...'},T('Myspace Profile'));
        print $q->end_div();
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Bookmarking'));
        print $q->a({-class=>'local', -href=>'http://www.digg.com/users/xterminus/dugg',-title=>'Digg is for Morons like me'},T('My Digg Profile'));
        print $q->a({-class=>'local', -href=>'http://del.icio.us/cmauch',-title=>'mmmm... yummy'},T('Delicious Links'));
        print $q->end_div();
        print $q->start_div({-class=>'sideblock'});
        print $q->p({-class=>'sidetitle'},T('Short Bio'));
        PrintWikiToHTML(GetPageContent(CharlesMauchBio));
        print $q->end_div();
    }
    # Must be called after content, so sidbar must be called afterwords
    print CustomGetSisterSites($id);
    print CustomGetNearLinksUsed($id) unless GetParam('search', '') ne '' ; # Don't display dumb page in search results

    # Show Article info if ID is defined, ID is not a comment, ID is not a link, or Editor is not involked 
    if (($id ne undef) && ($id !~ /^Comments.*/) && ($id !~ /Links/) && ($id !~ /^Journal/) && (GetParam('action', '') ne 'edit')) {
        if ($id =~ /^\d\d\d\d-\d\d-\d\d.*/) {
            print $q->start_div({-class=>'sideinline'});
            print $q->p({-class=>'sidetitle'},T('About this Page'));
            print "<p>This is <strong>" . unCamel($id) . "</strong>, which is a part of my <a href=\"/Journal\" title=\"Charles Mauch's Blog\">Journal</a>." .  GetFooterTimestamp($id, $rev) . "<p>You can edit this page by doubleclicking on a blank area.<p><p>You can also leave a <a href=\"/Comments_on_" . $id . "\" title=\"Leave feedback on $id\">comment</a>.</p>";
            print $q->end_div();
        } else {
            print $q->start_div({-class=>'sideinline'});
            print $q->p({-class=>'sidetitle'},T('About this Page'));
            print GetFooterTimestamp($id, $rev) . "<p>You can edit this page by doubleclicking on any blank area.</p><p> You can also leave a <a href=\"/Comments_on_" . $id . "\" title=\"Leave feedback on $id\">comment</a>.</p>";
            # , or report a <a href=\"/?action=edit;id=ConcernsDefectsIssues_on_" . $id . "\">Concern, Defect, or Issue</a></p>";
            print $q->end_div();
        }
    }

    if ($id eq $HomePage) {
        print $q->start_div({-class=>'sideinline'});
        print $q->p({-class=>'sidetitle'},T('Colophon'));
        print "<p>Powered by a hugely <a href=\"/OddMuseHacks\" title=\"Internal page: Oddmuse Hacks\">hacked</a> version of <a href=\"http://www.oddmuse.org\" title=\"External link to: Oddmuse Wiki Homepage\">oddmuse</a>, <a href=\"http://www.perl.org\" title=\"Perl Programming Language\">perl</a>, and <a href=\"http://www.apache.org\" title=\"Apache Webserver\">apache</a>.</p>";
        print $q->end_div();
    }

    print $q->end_div();
    print $q->start_div({-class=>'sidefooter'}), $q->end_div();
    print $q->end_div(); # End clear
    print $q->end_div(); 
    print $q->end_div();
    print $q->end_div();
    print $q->end_div();
    print $q->end_div();
}
1;
